import request from "./request";

// 获取歌单列表
export function getSongsList(limit, offset = 0) {
    return request({
        url: "/top/playlist",
        params: {
            limit,
            offset
        }
    });
}

export function getCategory() {
    return request({
        url: "/playlist/catlist"
    });
}

//可选参数 : order: 可选值为 'new' 和 'hot', 分别对应最新和最热 , 默认为 'hot'
export function loadCategorySongs(cat = "全部", offset = 0, limit = 35, order) {
    let params = order ?
        {
            cat,
            limit,
            offset,
            order
        } :
        {
            cat,
            limit,
            offset
        };
    return request({
        url: "/top/playlist",
        params: {
            ...params
        }
    });
}

// 点赞
/* cid : 评论 id
t : 是否点赞 ,1 为点赞 ,0 为取消点赞 */
export function sendLikeComment(id, cid, t, cookie) {
    return request({
        url: "/comment/like",
        params: {
            id,
            cid,
            t,
            type: 0,
            cookie
        }
    });
}

/* 收藏歌单, 传递歌单id */
export function sendCollectSongsList(id, cookie) {
    return request({
        url: "/playlist/subscribe",
        params: {
            t: 1,
            id,
            cookie
        }
    });
}